#ifndef _OPERAND_H
#define _OPERAND_H

#include <iostream>
#include <string>

using namespace std;

#define MAX32 0xffffffff

// type of operands, can be variable, register, wire or =,+,-,*,/,()
enum OperandType
{
	OPERAND_VAR,
	OPERAND_REG,
	OPERAND_WIRE,
	OPERAND_CONST,
	OPERAND_ASSIGN,
	OPERAND_NEG,
	OPERAND_PLUS,
	OPERAND_MINUS,
	OPERAND_MUL,
	OPERAND_DIV,
	OPERAND_POSEDGE,
	OPERAND_NEGEDGE
};

enum OperandState
{
	STATE_REGULAR,
	STATE_POSEDGE,
	STATE_NEGEDGE
};

class Operand
{
public:
	Operand(){}
	Operand(OperandType type, int value, string name);

	void SetValue( int value );

	void UpdateState();

	void SetState( OperandState state ) { this->state = state; }
	OperandState GetState() { return this->state; }
	int GetValue() { return this->value; }
	OperandType GetType() { return this->type; }
	string GetName() { return this->name; }

	void Print()
	{
		std::cout << this->GetName().c_str() << " ";
	}
	
	void PrintTrace()
	{
		cout << "\t" << this->GetName().c_str() << " = " << this->GetValue() << endl;
	}

	~Operand(){}
private:
	OperandType type;
	OperandState state;
	string name;
	int value;
	int prevValue;
};

#endif
